<template>
  <div>
    <el-dialog title="进行评价" width="30%" :visible.sync="addEv.visible" :before-close="evaluateClose">
      <el-input
        v-model="content"
        placeholder="请输入内容"
        type="textarea"
        :rows="5"
      ></el-input>
      <span slot="footer" class="dialog-footer">
        <el-button @click="evaluateClose">取消</el-button>
        <el-button type="primary" @click="add()">添加</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { addEvaluate } from "../../api/evaluate";
export default {
  props: ["addEv"],
  name: "addEvaluate",
  data() {
    return {
      dialogVisible: true,
      good_id: 0,
      u_id: 0,
      content: "",
      praise: 0,
      negative: 0,
      state: 1,
    };
  },
  methods: {
    // 添加评论
    add() {
      console.log(this.addEv);
      var good_id = this.addEv.good_id;
      var u_id = this.addEv.u_id;
      var content = this.content;
      var praise = this.praise;
      var negative = this.negative;

      var data = {
        good_id: good_id,
        u_id: u_id,
        content: content,
        praise: praise,
        negative: negative,
        state: 1,
      };
      console.log(data)
      addEvaluate(data).then((res) => {
        console.log("`````````````````````````");
        console.log(res);
        if (res == 1) {
          this.$message.success("提交成功");
        } else {
          this.$message.error("提交失败");
        }
        this.evaluateClose()
      });
    },
    // 关闭评论弹窗
    evaluateClose() {
      this.$emit("evaluateClose")
    }
  },
};
</script>

<style></style>
